<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
    // 可选链式操作符  ?
    var obj ={
        myname:"adf",
        hobby:{
            one:"篮球"
        }
    }
    console.log(obj?.hobby?.one);

    // 空合并运算符 ??类似||
    function fn(a,b){
        var a = a ?? 1;
        var b = b ?? 2;
        console.log(a,b);
    }
    fn(10,"")


    // interator迭代器 数组 map set 内置迭代器
    var arr1 = [1,2,3,4];
    console.log(arr1);

    var map = new Map([['name',"张三"]]);
    console.log(map);

    // interator 会提供一个方法和两个属性
    let arr = ["张三","李四","王五"];
    var interatorObj = arr[Symbol.iterator]();
    console.log(interatorObj);
    console.log(interatorObj.next());
    console.log(interatorObj.next());
    console.log(interatorObj.next());
    console.log(interatorObj.next());


    // 内置迭代器的数据可以使用 for of 循环
    for(let val of arr){
        console.log(val);
    }

    // 内置 enteries 方法
    console.log(arr.entries());
    for(let val of arr.entries()){
        console.log(val);
    }
    for(let [key,item] of arr.entries()){
        console.log(key,item);
    }



</script>